import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    proxy: {
      // 代理天气API
      '/api/weather': {
        target: 'http://t.weather.itboy.net',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/weather/, '/api/weather')
      },
      // 代理华为云IAM API
      '/huawei-iam': {
        target: 'https://iam.cn-south-1.myhuaweicloud.com',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/huawei-iam/, '')
      },
      // 代理华为云IoT API
      '/huawei-iot': {
        target: 'https://258b41b5d3.st1.iotda-app.cn-south-1.myhuaweicloud.com',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/huawei-iot/, '')
      }
    }
  }
})
